package no.ntnu.fp.model1;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

public class Comment implements ActionListener {

	JButton checkButton, checkButton1, checkButton2;
	JButton sub;
	JButton close;
	JTextArea jta;
	JFrame frame;
	int wellId = 0;
	Well well;
	String s2;
	
	public Comment(){
		
	}
	
	private JPanel createTextArea(String s){
		JPanel out = new JPanel();
		jta = new JTextArea("<Insert comment here>", 9, 28);
		jta.setBounds(0, 0, 300, 150);
		out.add(jta);
		return out;
	}

	protected void createGui(String s){
		s2 = s;
		createGui();
	}
	
	protected void createGui(){
		frame = new JFrame("Comment");
		frame.setResizable(false);
		//frame.setUndecorated(true);
		//frame.setLocationByPlatform(true);
		//frame.setLocationRelativeTo(null);
		frame.setLocation(700,330);
		frame.setAlwaysOnTop(true);
		JPanel panel = new JPanel(new BorderLayout());
		TitledBorder title;
		title = BorderFactory.createTitledBorder("Comment");
		panel.setBorder(title);
		
		JPanel subP = new JPanel(new GridLayout(0, 2));

		panel.add(createTextArea(s2));
		close = new JButton("Close");
		close.addActionListener(this);
		subP.add(close, BorderLayout.SOUTH);
		sub = new JButton("Submit");
		sub.addActionListener(this);
		subP.add(sub, BorderLayout.SOUTH);
		panel.add(subP, BorderLayout.PAGE_END);
		
		frame.setContentPane(panel);
				
		frame.pack();
		frame.setSize(350, 250);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}
	
	public static void main(String[] args){
		new wellGui().createGui();
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		//System.out.println("You pushed a button");
		int nr = 0;
		//System.out.println(e);
		if(e.getSource()==close){
			wellGui.setFrameUp(false);
			frame.hide();
			//new lwsGui().createGui();
		}else if(e.getSource()==checkButton){
			nr = 1;
		}else if(e.getSource()==checkButton2){
			nr = 2;
		}else if(e.getSource()==sub){
			System.out.println("Comment submitted");
			jta.setText("Comment submitted!");
			//submit
		}
		//System.out.println("nr "+nr);
	}
	
}
